package com.gt.admin.controller;

import com.gt.common.core.domain.AjaxResult;
import com.gt.admin.domain.apiVO.CheckQualityResult;
import com.gt.admin.domain.apiVO.FlowQualityResult;
import com.gt.admin.domain.apiVO.QuestionnaireQualityResult;
import com.gt.admin.domain.vo.*;
import com.gt.admin.service.ICountListConfigService;
import com.gt.admin.utils.CountListType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@Api(tags = "sc-筛查质控分析")
@RestController
@RequestMapping("/quality-control-analysis")
public class QualityControlAnalysisController {
    @Autowired
    private ICountListConfigService countListConfigService;

    /**
     * 筛查问卷质控
     */
    @ApiOperation(value = "筛查问卷质控")
    @GetMapping("/questionnaire")
    public AjaxResult questionnaireQuality(CountTime countTime){
        if (countTime.getSickId() == null){
            countTime.setSickId(0L);
        }
        List<QuestionnaireCommit> commitList = new ArrayList<>();
        commitList.add(QuestionnaireCommit.builder()
                .area("遵义市汇川区")
                .commitNum(468)
                .effectiveCheckNum(433)
                .effectivePercent("95%")
                .highRiskNum(25)
                .lowRiskNum(219).build());
        commitList.add(QuestionnaireCommit.builder()
                .area("遵义县")
                .commitNum(331)
                .effectiveCheckNum(254)
                .effectivePercent("81%")
                .highRiskNum(64)
                .lowRiskNum(155).build());
        commitList.add(QuestionnaireCommit.builder()
                .area("桐梓县")
                .commitNum(234)
                .effectiveCheckNum(231)
                .effectivePercent("99%")
                .highRiskNum(120)
                .lowRiskNum(133).build());
        List<CoreIndex> indexList = new ArrayList<>();
        indexList.add(CoreIndex.builder()
                .area("遵义市汇川区")
                .questionnaireNum(442L)
                .index1(88L)
                .index2(179L)
                .index3(301L)
                .index4(268L)
                .index5(106L)
                .index6(95L)
                .index7(67L)
                .index8(59L).build());
        indexList.add(CoreIndex.builder()
                .area("遵义县")
                .questionnaireNum(339L)
                .index1(74L)
                .index2(151L)
                .index3(267L)
                .index4(208L)
                .index5(46L)
                .index6(68L)
                .index7(49L)
                .index8(46L).build());
        indexList.add(CoreIndex.builder()
                .area("桐梓县")
                .questionnaireNum(123L)
                .index1(34L)
                .index2(45L)
                .index3(23L)
                .index4(43L)
                .index5(53L)
                .index6(65L)
                .index7(76L)
                .index8(12L).build());
        QueCoreIndexList queCoreIndexList = QueCoreIndexList.builder()
                .headerList(countListConfigService.getHeader(countTime.getSickId(), CountListType.QUE_CORE_INDEX))
                .indexList(indexList).build();
        QuestionnaireQualityResult result = QuestionnaireQualityResult.builder()
                .commitList(commitList)
                .queCoreIndexList(queCoreIndexList).build();
        return AjaxResult.success(result);
    }

    /**
     * 筛查检查质控
     */
    @ApiOperation(value = "筛查检查质控")
    @GetMapping("/check")
    public AjaxResult checkQuality(CountTime countTime){
        if (countTime.getSickId() == null){
            countTime.setSickId(0L);
        }
        List<CheckIndex> checkIndexList = new ArrayList<>();
        checkIndexList.add(CheckIndex.builder()
                .hospital("遵义附医")
                .checkNum(449)
                .assessHighRiskNum(238)
                .siftingCaseNum(325)
                .lesionInfo("息肉")
                .lesionMatchNum(89)
                .lesionMatchPercent("89%")
                .biopsyNum(129)
                .biopsyPercent("82%")
                .cureNum(334)
                .curePercent("94%").build());
        checkIndexList.add(CheckIndex.builder()
                .hospital("遵义二医")
                .checkNum(404)
                .assessHighRiskNum(220)
                .siftingCaseNum(368)
                .lesionInfo("息肉")
                .lesionMatchNum(66)
                .lesionMatchPercent("59%")
                .biopsyNum(76)
                .biopsyPercent("62%")
                .cureNum(357)
                .curePercent("91%").build());
        checkIndexList.add(CheckIndex.builder()
                .hospital("遵义市妇幼保健院")
                .checkNum(351)
                .assessHighRiskNum(200)
                .siftingCaseNum(255)
                .lesionInfo("息肉")
                .lesionMatchNum(40)
                .lesionMatchPercent("59%")
                .biopsyNum(80)
                .biopsyPercent("62%")
                .cureNum(300)
                .curePercent("93%").build());
        List<DiagnosisIndex> indexList = new ArrayList<>();
        indexList.add(DiagnosisIndex.builder()
                .hospital("遵义附医")
                .checkNum(599L)
                .assessHighRiskNum(255L)
                .diaIndex1("344")
                .diaIndex2("268")
                .diaIndex3("66%")
                .diaIndex4("177")
                .diaIndex5("72")
                .diaIndex6("68%")
                .diaIndex7("79")
                .diaIndex8("45%").build());
        indexList.add(DiagnosisIndex.builder()
                .hospital("遵义二医")
                .checkNum(592L)
                .assessHighRiskNum(265L)
                .diaIndex1("314")
                .diaIndex2("208")
                .diaIndex3("67%")
                .diaIndex4("197")
                .diaIndex5("79")
                .diaIndex6("64%")
                .diaIndex7("77")
                .diaIndex8("44%").build());
        indexList.add(DiagnosisIndex.builder()
                .hospital("遵义市妇幼保健院")
                .checkNum(592L)
                .assessHighRiskNum(265L)
                .diaIndex1("322")
                .diaIndex2("231")
                .diaIndex3("67%")
                .diaIndex4("241")
                .diaIndex5("67")
                .diaIndex6("75%")
                .diaIndex7("88")
                .diaIndex8("51%").build());
        DiagnosisIndexList diagnosisIndexList = DiagnosisIndexList.builder()
                .headerList(countListConfigService.getHeader(countTime.getSickId(), CountListType.DIAGNOSIS_INDEX))
                .indexList(indexList).build();
        List<CureIndex> indexList2 = new ArrayList<>();
        indexList2.add(CureIndex.builder()
                .hospital("遵义附医")
                .checkNum(599L)
                .assessHighRiskNum(250L)
                .cureNum(200L)
                .cure1("50")
                .cure2("20")
                .cure3("10")
                .cure4("100")
                .cure5("10")
                .cure6("10")
                .cure7("80")
                .cure8("120").build());
        indexList2.add(CureIndex.builder()
                .hospital("遵义二医")
                .checkNum(592L)
                .assessHighRiskNum(250L)
                .cureNum(200L)
                .cure1("50")
                .cure2("20")
                .cure3("10")
                .cure4("100")
                .cure5("10")
                .cure6("10")
                .cure7("80")
                .cure8("120").build());
        indexList2.add(CureIndex.builder()
                .hospital("遵义市妇幼保健院")
                .checkNum(592L)
                .assessHighRiskNum(250L)
                .cureNum(200L)
                .cure1("60")
                .cure2("25")
                .cure3("15")
                .cure4("100")
                .cure5("10")
                .cure6("10")
                .cure7("80")
                .cure8("120").build());
        CureIndexList cureIndexList = CureIndexList.builder()
                .headerList(countListConfigService.getHeader(countTime.getSickId(), CountListType.CURE_INDEX))
                .indexList(indexList2).build();
        CheckQualityResult checkQualityResult = CheckQualityResult.builder()
                .checkIndexList(checkIndexList)
                .diagnosisIndexList(diagnosisIndexList)
                .cureIndexList(cureIndexList).build();
        return AjaxResult.success(checkQualityResult);
    }

    /**
     * 筛查随访质控
     */
    @ApiOperation(value = "筛查随访质控")
    @GetMapping("/flow")
    public AjaxResult flowQuality(CountTime countTime){
        if (countTime.getSickId() == null){
            countTime.setSickId(0L);
        }
        List<CheckDiagnosisIndex> diagnosisIndexList = new ArrayList<>();
        diagnosisIndexList.add(CheckDiagnosisIndex.builder()
                .hospital("遵义附医")
                .checkNum(365)
                .assessHighRiskNum(109)
                .screenNum(361)
                .flowNum(288)
                .lossFlowNum(15)
                .lossFlowPercent("8%")
                .recheckNum(164)
                .recheckPercent("67%").build());
        diagnosisIndexList.add(CheckDiagnosisIndex.builder()
                .hospital("遵义二医")
                .checkNum(328)
                .assessHighRiskNum(95)
                .screenNum(319)
                .flowNum(298)
                .lossFlowNum(13)
                .lossFlowPercent("8%")
                .recheckNum(119)
                .recheckPercent("63%").build());
        diagnosisIndexList.add(CheckDiagnosisIndex.builder()
                .hospital("遵义市妇幼保健院")
                .checkNum(341)
                .assessHighRiskNum(100)
                .screenNum(300)
                .flowNum(270)
                .lossFlowNum(19)
                .lossFlowPercent("10%")
                .recheckNum(210)
                .recheckPercent("65%").build());
        List<CheckCureIndex> cureIndexList = new ArrayList<>();
        cureIndexList.add(CheckCureIndex.builder()
                .hospital("遵义附医")
                .checkNum(365)
                .assessHighRiskNum(109)
                .cureNum(99)
                .completeFlow(72)
                .firstStage(113)
                .secondStage(94)
                .thirdStage(85)
                .fourthStage(48)
                .lossFlowNum(16)
                .lossFlowPercent("12%")
                .recheckNum(89)
                .recheckPercent("86%").build());
        cureIndexList.add(CheckCureIndex.builder()
                .hospital("遵义二医")
                .checkNum(338)
                .assessHighRiskNum(96)
                .cureNum(84)
                .completeFlow(68)
                .firstStage(92)
                .secondStage(89)
                .thirdStage(65)
                .fourthStage(59)
                .lossFlowNum(8)
                .lossFlowPercent("8%")
                .recheckNum(79)
                .recheckPercent("75.6%").build());
        cureIndexList.add(CheckCureIndex.builder()
                .hospital("遵义市妇幼保健院")
                .checkNum(341)
                .assessHighRiskNum(100)
                .cureNum(89)
                .completeFlow(70)
                .firstStage(95)
                .secondStage(90)
                .thirdStage(70)
                .fourthStage(62)
                .lossFlowNum(10)
                .lossFlowPercent("11%")
                .recheckNum(81)
                .recheckPercent("79%").build());
        FlowQualityResult result = FlowQualityResult.builder().build();
        result.setDiagnosisIndexList(diagnosisIndexList);
        result.setCureIndexList(cureIndexList);
        return AjaxResult.success(result);
    }
}
